<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>img - complete attribute</title>
  </head>

  <body>
    <img id="img1" src="http://pic1.win4000.com/wallpaper/f/51c3bb99a21ea.jpg" />
    <p id="p1">loading...</p>
    <script type="text/javascript">
      function imgLoad(img, callback) {
        let timer = setInterval(function () {
          console.log(img.complete);
          if (img.complete) {
            clearInterval(timer);
            callback();
          }
        }, 50);
      }
      imgLoad(img1, function () {
        p1.innerHTML = '加载完毕';
      });
    </script>
  </body>
</html>
